<!DOCTYPE HTML>
    <html>

    <head>
        <meta charset="utf-8">
        <meta name="renderer" content="webkit|ie-comp|ie-stand">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
        <meta http-equiv="Cache-Control" content="no-siteapp" />
        <link rel="Bookmark" href="/favicon.ico">
        <link rel="Shortcut Icon" href="/favicon.ico" />
        <!--[if lt IE 9]>
        <script type="text/javascript" src="/admin/lib/html5shiv.js"></script>
        <script type="text/javascript" src="/admin/lib/respond.min.js"></script>
        <![endif]-->
        <link rel="stylesheet" type="text/css" href="/admin/static/h-ui/css/H-ui.min.css" />
        <link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/H-ui.admin.css" />
        <link rel="stylesheet" type="text/css" href="/admin/lib/Hui-iconfont/1.0.8/iconfont.css" />
        <link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/skin/default/skin.css" id="skin" />
        <link rel="stylesheet" type="text/css" href="/admin/static/h-ui.admin/css/style.css" />
        <!--[if IE 6]>
        <script type="text/javascript" src="/admin/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
        <script>DD_belatedPNG.fix('*');</script>
        <![endif]-->
        <title>商品列表</title>
    </head>

    <body>
        <nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 商品管理 <span class="c-gray en">&gt;</span> 商品列表 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新"><i class="Hui-iconfont">&#xe68f;</i></a></nav>
        <div class="page-container">
            <form class="Huiform" method="post" action="/admin/item/search" target="_self">
                <input type="hidden" name="_token" value="{{csrf_token()}}">
                <div class="text-c">
                    <span class="select-box inline">
                        <select name="shaixuan" class="select">
                            <option value="0">全部</option>
                            <option value="1"
                            @if(isset($shaixuan) && $shaixuan == '1')
                               selected
                            @endif>顶部轮播图</option>
                            <option value="2"
                            @if(isset($shaixuan) && $shaixuan == '2')
                                selected
                            @endif>首页热点</option>
                        </select>
                    </span>
                    <span class="select-box inline">
                        <select name="class_id" class="select">
                            <option value="0">全部</option>
                            @foreach($class as $val)
                                <option value="{{$val -> id}}"
                                @if(isset($class_id) && $val -> id == $class_id)
                                selected
                                @endif>{{$val -> classification_name}}</option>
                            @endforeach
                        </select>
                    </span>
                    日期范围：
                    <input type="text" onfocus="WdatePicker({ maxDate:'#F{$dp.$D(\'datemax\')||\'%y-%M-%d\'}' })" id="datemin" name="datemin" class="input-text Wdate" style="width:120px;"> -
                    <input type="text" onfocus="WdatePicker({ minDate:'#F{$dp.$D(\'datemin\')}',maxDate:'%y-%M-%d' })" id="datemax" name="datemax" class="input-text Wdate" style="width:120px;">
                    <input type="text" class="input-text" style="width:250px" placeholder="输入商品名称" id="" name="key">
                    <button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜商品名称</button>
                </div>
            </form>
            <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> <a href="javascript:;" onclick="item_add('添加商品','/admin/item/add','800','500')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加商品</a></span> <span class="r">共有数据：<strong>{{count($data)}}</strong> 条</span> </div>
            <table class="table table-border table-bordered table-bg">
                <thead>
                    <tr>
                        <th scope="col" colspan="15">商品列表</th>
                    </tr>
                    <tr class="text-c">
                        <th width="5%">
                            <input type="checkbox" id="checkbox-1" value="" name="">
                        </th>
                        <th width="5%">ID</th>
                        <th width="40%">商品信息</th>
                        <th width="20%">商品主图</th>
                        <th width="5%">排序</th>
                        <th width="5%">状态</th>
                        <th width="20%">操作</th>
                    </tr>
                </thead>
                <tbody>
                	@foreach($data as $val)
                    <tr class="text-c">
                        <td>
                            <input type="checkbox" id="checkbox-1" value="{{$val -> id}}" name="">
                        </td>
                        <td>{{$val -> id}}</td>
                        <td  class="text-l">
                            @if($val -> is_sowing_map == '1')
                                <a href="javascript:void(0);" onclick="del_sowing_map(this,'{{$val -> id}}');">
                                    <span class="label label-warning radius">TOP <i class="Hui-iconfont">&#xe60b;</i></span>
                                </a>
                            @endif
                            @if($val -> is_home_show == '1')
                                    <a href="javascript:void(0);" onclick="del_home_show(this,'{{$val -> id}}')">
                                        <span class="label label-danger radius">HOT <i class="Hui-iconfont">&#xe60b;</i></span>
                                    </a>
                                @endif
                            名称：{{$val -> item_name}}
                            <br/>产地：（{{$val -> place_of_origin}}）
                            <br/>总库存：{{$val -> stock}}&emsp;|&emsp;运费：{{$val -> express}}
                            <br/>销售价：{{$val -> item_price}}&emsp;|&emsp;市场价：{{$val -> item_mprice}}&emsp;|&emsp;进货价：{{$val -> item_cprice}}
                            <br/>月销量：{{$val -> monthly_sales}}&emsp;|&emsp;总销量：{{$val -> total_sales}}&emsp;|&emsp;收藏量：{{$val -> collection_num}}&emsp;|&emsp; 点击量：{{$val -> click_num}}
                        </td>
                        <td><img src="{{$val -> cover_img}}" width="100" data-toggle="popover" data-html="true"  data-content="<img src='{{$val -> cover_img}}' width='350'>" data-placement="right" ></td>
                        <td>{{$val -> sort}}</td>
                        <td class="td-status">
                        @if($val -> status == '2')
                        <span class="label label-success radius">正常</span>
                        @else
                        <span class="label radius">已下架</span>
                        @endif
                        </td>
                        <td class="td-manage">
                        @if($val -> status == '2')
                        <a style="text-decoration:none" onClick="item_stop(this,'{{$val -> id}}')" href="javascript:;" title="下架"><i class="Hui-iconfont">&#xe631;</i></a>
                        @else
                        <a style="text-decoration:none" onClick="item_start(this,'{{$val -> id}}')" href="javascript:;" title="上架"><i class="Hui-iconfont">&#xe615;</i></a>
                        @endif
                        <a title="编辑" href="javascript:;" onclick="item_edit('商品编辑','/admin/item/edit','{{$val -> id}}','800','500')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
                        <a title="删除" href="javascript:;" onclick="item_del(this,'{{$val -> id}}')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6e2;</i></a>&nbsp;|&nbsp;
                        <a data-title="商品列表" data-href="/admin/user_item_comment/search?item_id={{$val -> id}}" onclick="Hui_admin_tab(this)" href="javascript:void(0);"> 查看评论</a>
                            <br/>
                            <br/>
                        <input class="btn btn-success-outline size-MINI radius" onclick="show_detail(this,'{{$val -> id}}')" type="button" value="相册&库存">
                        @if($val -> is_sowing_map == '1')
                            <input class="btn btn-warning-outline size-MINI radius" onclick="show_sowing_map(this,'{{$val -> id}}')" type="button" value="轮播图">
                        @endif
                        @if($val -> is_home_show == '1')
                            <input class="btn btn-danger-outline size-MINI radius" onclick="show_home_show(this,'{{$val -> id}}')" type="button" value="热点图">
                        @endif
                        </td>
                    </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
        <div id="modal-demo" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content radius">
                    <div class="modal-header">
                        <h3 class="modal-title">首页顶部轮播图</h3>
                        <a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:void(0);">×</a>
                    </div>
                    <div class="modal-body">
                        <img src="" alt="" style="width: 100%;" id="img1">
                        <input class="input-text upload-url radius" type="text" name="uploadfile-1" id="uploadfile-1" readonly>
                        <div id="uploader-demo">
                            <div id="fileList" class="uploader-list"></div>
                            <div id="filePicker"><i class="icon Hui-iconfont">&#xe642;</i>更换图片</div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button class="btn btn-primary" id="modal-demo-submit">确定</button>
                        <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
                    </div>
                </div>
            </div>
        </div>
        <div id="modal-demo1" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content radius">
                    <div class="modal-header">
                        <h3 class="modal-title">首页热点图</h3>
                        <a class="close" data-dismiss="modal" aria-hidden="true" href="javascript:void(0);">×</a>
                    </div>
                    <div class="modal-body">
                        <form action="" class="form form-horizontal">
                            <div class="row cl">
                                <label class="form-label col-xs-4 col-sm-3">标签：</label>
                                <div class="formControls col-xs-8 col-sm-9">
                                    <input name="tags" type="text" class="input-text" autocomplete="off" placeholder="标签">
                                </div>
                            </div>
                            <div class="row cl">
                                <label class="form-label col-xs-4 col-sm-3"></label>
                                <div class="formControls col-xs-8 col-sm-9">
                                    <img src="" alt="" style="width: 50%;" id="img2">
                                </div>
                            </div>
                            <div class="row cl">
                                <label class="form-label col-xs-4 col-sm-3"></label>
                                <div class="formControls col-xs-8 col-sm-9">
                                    <input class="input-text upload-url radius" type="text" name="uploadfile-1" id="uploadfile-1" readonly>
                                    <div id="uploader-demo">
                                        <div id="fileList1" class="uploader-list"></div>
                                        <div id="filePicker1"><i class="icon Hui-iconfont">&#xe642;</i>更换图片</div>
                                    </div>
                                </div>
                            </div>
                        </form>

                    </div>
                    <div class="modal-footer">
                        <button class="btn btn-primary" id="modal-demo1-submit">确定</button>
                        <button class="btn" data-dismiss="modal" aria-hidden="true">关闭</button>
                    </div>
                </div>
            </div>
        </div>
        <!--_footer 作为公共模版分离出去-->
        <script type="text/javascript" src="/admin/lib/jquery/1.9.1/jquery.min.js"></script>
        <script type="text/javascript" src="/admin/lib/layer/2.4/layer.js"></script>
        <script type="text/javascript" src="/admin/static/h-ui/js/H-ui.min.js"></script>
        <script type="text/javascript" src="/admin/static/h-ui.admin/js/H-ui.admin.js"></script>
        <!--/_footer 作为公共模版分离出去-->
        <!--请在下方写此页面业务相关的脚本-->
        <script type="text/javascript" src="/admin/lib/My97DatePicker/4.8/WdatePicker.js"></script>
        <script type="text/javascript" src="/admin/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
        <script type="text/javascript" src="/admin/lib/laypage/1.2/laypage.js"></script>
        <!--引入webuploader相关文件-->
        <link rel="stylesheet" type="text/css" href="/admin/webuploader-0.1.5/webuploader.css">
        <script type="text/javascript" src="/admin/webuploader-0.1.5/webuploader.js"></script>
        <!--引入webuploader相关文件-->
        <script type="text/javascript">
            jQuery(function() {
                var $ = jQuery,
                        $list = $('#fileList'),
                        $list1 = $('#fileList1'),
                // 优化retina, 在retina下这个值是2
                        ratio = window.devicePixelRatio || 1,
                // 缩略图大小
                        thumbnailWidth = 100 * ratio,
                        thumbnailHeight = 100 * ratio,
                // Web Uploader实例
                        uploader,
                        uploader1,


                // 初始化Web Uploader
                uploader = WebUploader.create({
                    //往请求中添加token
                    formData:{
                        '_token': "{{csrf_token()}}",
                        'img_type':'sowing_map_img',
                        'qiniu_type':'qiniu_item'
                    },
                    // 自动上传。
                    auto: true,
                    // swf文件路径
                    swf: '/admin/webuploader-0.1.5/Uploader.swf',
                    // 文件接收服务端。
//        server: '/admin/upload/img_default',
                    server: '/admin/upload/qiniu',
                    // 选择文件的按钮。可选。
                    // 内部根据当前运行是创建，可能是input元素，也可能是flash.
                    pick: '#filePicker',
                    // 只允许选择文件，可选。
                    accept: {
                        title: 'Images',
                        extensions: 'gif,jpg,jpeg,bmp,png,webp',
                        mimeTypes: 'image/gif,image/jpg,image/jpeg,image/bmp,image/png,image/webp'
                    }
                });
                uploader1 = WebUploader.create({
                    formData:{
                        '_token': "{{csrf_token()}}",
                        'img_type':'tags_img',
                        'qiniu_type':'qiniu_item'
                    },
                    auto: true,
                    swf: '/admin/webuploader-0.1.5/Uploader.swf',
                    server: '/admin/upload/qiniu',
                    pick: '#filePicker1',
                    accept: {
                        title: 'Images',
                        extensions: 'gif,jpg,jpeg,bmp,png,webp',
                        mimeTypes: 'image/gif,image/jpg,image/jpeg,image/bmp,image/png,image/webp'
                    }
                });



                // 当有文件添加进来的时候
                uploader.on( 'fileQueued', function( file ) {
                    $('#img1').remove();
                    var $li = $(
                                    '<div id="' + file.id + '" class="file-item thumbnail"><img><div class="info">' + file.name + '</div></div>'
                            ),
                            $img = $li.find('img');
                    //清除之前的预览区，只保留一个预览图
                    $('.thumbnail').remove();
                    $list.append( $li );
                    // 创建缩略图
                    uploader.makeThumb( file, function( error, src ) {
                        if ( error ) {
                            $img.replaceWith('<span>不能预览</span>');
                            return;
                        }
                        $img.attr( 'src', src );
                    }, thumbnailWidth, thumbnailHeight );
                });
                uploader1.on( 'fileQueued', function( file ) {
                    $('#img2').remove();
                    var $li = $('<div id="' + file.id + '" class="file-item thumbnai2"><img><div class="info">' + file.name + '</div></div>'),
                            $img = $li.find('img');
                    $('.thumbnai2').remove();
                    $list1.append( $li );
                    // 创建缩略图
                    uploader1.makeThumb( file, function( error, src ) {
                        if ( error ) {
                            $img.replaceWith('<span>不能预览</span>');
                            return;
                        }
                        $img.attr( 'src', src );
                    }, thumbnailWidth, thumbnailHeight );
                });

                // 文件上传过程中创建进度条实时显示。
                uploader.on( 'uploadProgress', function( file, percentage ) {
                    var $li = $( '#'+file.id ),
                            $percent = $li.find('.progress span');
                    // 避免重复创建
                    if ( !$percent.length ) {
                        $percent = $('<p class="progress"><span></span></p>')
                                .appendTo( $li )
                                .find('span');
                    }
                    $percent.css( 'width', percentage * 100 + '%' );
                });
                uploader1.on( 'uploadProgress', function( file, percentage ) {
                    var $li = $( '#'+file.id ),
                            $percent = $li.find('.progress span');
                    if ( !$percent.length ) {
                        $percent = $('<p class="progress"><span></span></p>').appendTo( $li ).find('span');
                    }
                    $percent.css( 'width', percentage * 100 + '%' );
                });


                // 文件上传成功，给item添加成功class, 用样式标记上传成功。，其第2个参数是ajax返回值
                uploader.on( 'uploadSuccess', function( file,data ) {
                    $( '#'+file.id ).addClass('upload-state-done');
                    //将路径给放到隐藏域中
                    $('#modal-demo').find('#uploadfile-1').val(data.path);
                    layer.msg(data.message,{icon: '6'});
                });
                uploader1.on( 'uploadSuccess', function( file,data ) {
                    $( '#'+file.id ).addClass('upload-state-done');
                    $('#modal-demo1').find('#uploadfile-1').val(data.path);
                    layer.msg(data.message,{icon: '6'});
                });


                // 文件上传失败，现实上传出错。
                uploader.on( 'uploadError', function( file ) {
                    var $li = $( '#'+file.id ),
                            $error = $li.find('div.error');
                    // 避免重复创建
                    if ( !$error.length ) {
                        $error = $('<div class="error"></div>').appendTo( $li );
                    }
                    $error.text('上传失败');
                });
                uploader1.on( 'uploadError', function( file ) {
                    var $li = $( '#'+file.id ),
                            $error = $li.find('div.error');
                    if ( !$error.length ) {
                        $error = $('<div class="error"></div>').appendTo( $li );
                    }
                    $error.text('上传失败');
                });

                // 完成上传完了，成功或者失败，先删除进度条。
                uploader.on( 'uploadComplete', function( file ) {
                    $( '#'+file.id ).find('.progress').remove();
                });
                uploader1.on( 'uploadComplete', function( file ) {
                    $( '#'+file.id ).find('.progress').remove();
                });

            });
            $(function(){
                $('.skin-minimal input').iCheck({
                    checkboxClass: 'icheckbox-blue',
                    radioClass: 'iradio-blue',
                    increaseArea: '20%'
                });
                //实例化datatables
                $('table').dataTable({

                });
                $("[data-toggle='popover']").popover();

            });
        /*
        	参数解释：
        	title	标题
        	url		请求的url
        	id		需要操作的数据id
        	w		弹出层宽度（缺省调默认值）
        	h		弹出层高度（缺省调默认值）
        */
        /*商品-增加*/
        function item_add(title, url, w, h) {
            layer_show(title, url, w, h);
        }
        /*商品-删除*/
        function item_del(obj, id) {
            layer.confirm('确认要删除吗？', function(index) {
                $.ajax({
                    type: 'POST',
                    url: '/admin/item/del',
                    data: {id:id,_token:$("input[name='_token']").val()},
                    dataType: 'json',
                    success: function(data) {
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!', { icon: 1, time: 1000 });
                    },
                    error: function(data) {
                        console.log(data.msg);
                    },
                });
            });
        }

        /*商品-编辑*/
        function item_edit(title, url, id, w, h) {
            layer_show(title, url + '?id=' + id, w, h);
        }
        /*商品-下架*/
        function item_stop(obj, id) {
            layer.confirm('确认要下架吗？', function(index) {
                $.ajax({
                    type: 'POST',
                    url: '/admin/item/edit_status',
                    data: {id:id,status:'1',_token:$("input[name='_token']").val()},
                    dataType: 'json',
                    success: function(data) {
                        if(data == 1){
                            $(obj).parents("tr").find(".td-manage").prepend('<a onClick="item_start(this,id)" href="javascript:;" title="上架" style="text-decoration:none"><i class="Hui-iconfont">&#xe615;</i></a>');
                            $(obj).parents("tr").find(".td-status").html('<span class="label label-default radius">已下架</span>');
                            $(obj).remove();
                            layer.msg('已下架!', { icon: 5, time: 1000 });
                        }else{
                            layer.msg('修改失败!', { icon: 2, time: 1000 });
                        }
                    },
                    error: function(data) {
                        console.log(data.msg);
                    },
                });


            });
        }

        /*商品-上架*/
        function item_start(obj, id) {
            layer.confirm('确认要上架吗？', function(index) {
                $.ajax({
                    type: 'POST',
                    url: '/admin/item/edit_status',
                    data: {id:id,status:'2',_token:$("input[name='_token']").val()},
                    dataType: 'json',
                    success: function(data) {
                        if(data == 1){
                            $(obj).parents("tr").find(".td-manage").prepend('<a onClick="item_stop(this,id)" href="javascript:;" title="下架" style="text-decoration:none"><i class="Hui-iconfont">&#xe631;</i></a>');
                            $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">正常</span>');
                            $(obj).remove();
                            layer.msg('正常!', { icon: 6, time: 1000 });
                        }else{
                            layer.msg('修改失败!', { icon: 2, time: 1000 });
                        }
                    },
                    error: function(data) {
                        console.log(data.msg);
                    },
                });

            });
        }

        function show_detail(obj,id){
            if($(obj).closest('tr').next('.detail_biaoshi').length >= 1){
                return false;
            }
            $.ajax({
                type:'get',
                url:'/admin/item/detail',
                data:{id:id},
                dataType:'json',
                success: function (data) {
                    if(data.status == 200){
                        var detail_html = '<tr class="detail_biaoshi"><td colspan="13">' +
                                '<table class="table table-border table-bordered">' +
                                '<tbody>' +
                                '<tr><th class="va-m">商品详情：</th></tr>' +
                                '<tr>' +
                                '<td class="va-m">' +
                                '<div style="text-align: left;">' ;
                                if(data.info.img_list != ''){
                                    for(var i = 0; i < data.info.img_list.length; i++){
                                        detail_html += '<img src="'+data.info.img_list[i]+'" style="width:100px;">';
                                    }
                                }
                                detail_html += '</div>' +
                                '</td>' +
                                '</tr>';
                                if(data.info.stock != ''){
                                    detail_html += '<tr><td class="va-m">';
                                    for(var i = 0; i < data.info.stock.length; i++){
                                        detail_html += '<div style="float: left;margin: 10px;"><div><img src="'+data.info.stock[i].item_img+'" style="width:100px;"></div>';
                                        if(data.info.stock[i].item_attribute_ids != ''){
                                            detail_html += '<div style="color:#5eb95e;">商品属性：';
                                            for(var j = 0; j < data.info.stock[i].item_attribute_ids.length; j++){
                                                detail_html += data.info.stock[i].item_attribute_ids[j] + '&nbsp;&nbsp;';
                                            }
                                            detail_html +='</div>';
                                        }
                                        detail_html+= '</div>';
                                    }
                                    detail_html += '</td></tr>';
                                }
                                detail_html += '</tbody>' +
                                '</table>' +
                                '</td></tr>';

                        $(obj).closest('tr').after(detail_html);
                        $('.show_img').click(function(){
                            layer.tips('<img src="'+$(this).attr('src')+'">', this, {
                                tips: [3, '#fff'],
                                time: 4000
                            });
                        });
                    }else{
                        layer.msg(data.msg);
                    }
                 },
                error:function(xhr){}
            });


        }


            //显示修改轮播图弹窗
            function show_sowing_map(obj,item_id){
                $.ajax({
                    type:'get',
                    url:'/admin/item_sowing_map/getOne',
                    data:{item_id:item_id},
                    dataType:'json',
                    success: function (data) {
                        $('#modal-demo').attr('item_id',item_id);
                        $('#modal-demo').find('img').attr('src',data.item_img);
                        $('#modal-demo').find('#uploadfile-1').attr('value',data.item_img);
                        $("#modal-demo").modal("show");

                    },
                    error: function(xhr){}
                });

            }

            //显示修改热点图弹窗
            function show_home_show(obj,item_id){
                $.ajax({
                    type:'get',
                    url:'/admin/item_tags/getOne',
                    data:{item_id:item_id},
                    dataType:'json',
                    success: function (data) {
                        $('#modal-demo1').attr('item_id',item_id);
                        $('#modal-demo1').find('input[name=tags]').attr('value',data.tag);
                        $('#modal-demo1').find('img').attr('src',data.img);
                        $('#modal-demo1').find('#uploadfile-1').attr('value',data.img);
                        $("#modal-demo1").modal("show");
                    },
                    error: function(xhr){}
                });
            }

            //取消商品轮播图置顶
            function del_sowing_map(obj,item_id){
                layer.confirm('确定取消置顶轮播图？这将会删除所有有关信息！', {
                    btn: ['确定','取消'] //按钮
                }, function(){
                    $.ajax({
                        type:'post',
                        url:'/admin/item_sowing_map/del',
                        data:{item_id:item_id,_token:"{{csrf_token()}}"},
                        dataType:'json',
                        success: function (data) {
                            if(data == 1){
                                layer.msg('修改成功!', {
                                    icon: 1,
                                    time: 1000
                                });
                                var wait = 1;
                                var interval = setInterval(function(){
                                    var time = -- wait;
                                    if(time <= 0) {
                                        location.replace(location.href);
                                        clearInterval(interval);
                                    };
                                }, 1000);
                            }else{
                                layer.msg('修改失败!', {
                                    icon: 2,
                                    time: 1000
                                });
                            }
                        },
                        error:function(xhr){}
                    });
                }, function(){
                    layer.closeAll();
                });
            }

            //取消商品首页热点图
            function del_home_show(obj,item_id){
                layer.confirm('确定取消首页热点图？这将会删除所有有关信息！？', {
                    btn: ['确定','取消'] //按钮
                }, function(){
                    $.ajax({
                        type:'post',
                        url:'/admin/item_tags/del',
                        data:{item_id:item_id,_token:"{{csrf_token()}}"},
                        dataType:'json',
                        success: function (data) {
                            if(data == 1){
                                layer.msg('删除成功!', {
                                    icon: 1,
                                    time: 1000
                                });
                                var wait = 1;
                                var interval = setInterval(function(){
                                    var time = -- wait;
                                    if(time <= 0) {
                                        location.replace(location.href);
                                        clearInterval(interval);
                                    };
                                }, 1000);
                            }else if(data == 0){
                                layer.msg('修改失败!', {
                                    icon: 2,
                                    time: 1000
                                });
                            }else if(data.status == 0){
                                layer.msg(data.message, {
                                    icon: 2,
                                    time: 1000
                                });
                            }
                        },
                        error:function(xhr){}
                    });
                }, function(){
                    layer.closeAll();
                });
            }

            //保存轮播图
            $(document).on('click','#modal-demo-submit',function(){
                var item_id = $('#modal-demo').attr('item_id');
                var img = $('#modal-demo').find('#uploadfile-1').val();
                $.ajax({
                    type:'post',
                    url:'/admin/item_sowing_map/edit',
                    data:{item_id:item_id,item_img:img,_token:"{{csrf_token()}}"},
                    dataType:'json',
                    success: function (data) {
                        if(data == 1){
                            layer.msg('修改成功!', {
                                icon: 1,
                                time: 1000
                            });
                            var wait = 1;
                            var interval = setInterval(function(){
                                var time = -- wait;
                                if(time <= 0) {
                                    location.replace(location.href);
                                    clearInterval(interval);
                                };
                            }, 1000);
                        }else{
                            layer.msg('修改失败!', {
                                icon: 2,
                                time: 1000
                            });
                        }
                    },
                    error:function(xhr){}
                });
            });
            //保存热点图
            $(document).on('click','#modal-demo1-submit',function(){
                var item_id = $('#modal-demo1').attr('item_id');
                var tags = $('#modal-demo1').find('input[name=tags]').val();
                var img = $('#modal-demo1').find('#uploadfile-1').val();
                $.ajax({
                    type:'post',
                    url:'/admin/item_tags/edit',
                    data:{item_id:item_id,img:img,tag:tags,_token:"{{csrf_token()}}"},
                    dataType:'json',
                    success: function (data) {
                        if(data == 1){
                            layer.msg('修改成功!', {
                                icon: 1,
                                time: 1000
                            });
                            var wait = 1;
                            var interval = setInterval(function(){
                                var time = -- wait;
                                if(time <= 0) {
                                    location.replace(location.href);
                                    clearInterval(interval);
                                };
                            }, 1000);
                        }else{
                            layer.msg('修改失败!', {
                                icon: 2,
                                time: 1000
                            });
                        }
                    },
                    error:function(xhr){}
                });
            });

        </script>
    </body>

    </html>